Micron Document
🎖️GitЯра🎖️


Displaying Rendered • View rawDownload

core/ble/README.md f07624be882e679affc02931dc75e8cb1594de18 (f07624be) Text, 4.11 KB

T383838:core:ble

Module dependency graph

<!--region graph-->
T282828
Te6edf3graph Te6edf3TB
:Te6edf3coreTb4b4b4:Te6edf3bleTff7b72[Te6edf3bleTff7b72]Tff7b72:::Te6edf3kmpTff7b72-Te6edf3library

Te6edf3classDef Te6edf3androidTff7b72-Te6edf3application Te6edf3fillTb4b4b4:Te6edf3#CAFFBFTb4b4b4,Te6edf3strokeTb4b4b4:Te6edf3#000Tb4b4b4,Te6edf3strokeTff7b72-Te6edf3widthTb4b4b4:T79c0ff2Te6edf3pxTb4b4b4,Te6edf3colorTb4b4b4:Te6edf3#000Tb4b4b4;
Te6edf3classDef Te6edf3androidTff7b72-Te6edf3applicationTff7b72-Te6edf3compose Te6edf3fillTb4b4b4:Te6edf3#CAFFBFTb4b4b4,Te6edf3strokeTb4b4b4:Te6edf3#000Tb4b4b4,Te6edf3strokeTff7b72-Te6edf3widthTb4b4b4:T79c0ff2Te6edf3pxTb4b4b4,Te6edf3colorTb4b4b4:Te6edf3#000Tb4b4b4;
Te6edf3classDef Te6edf3composeTff7b72-Te6edf3desktopTff7b72-Te6edf3application Te6edf3fillTb4b4b4:Te6edf3#CAFFBFTb4b4b4,Te6edf3strokeTb4b4b4:Te6edf3#000Tb4b4b4,Te6edf3strokeTff7b72-Te6edf3widthTb4b4b4:T79c0ff2Te6edf3pxTb4b4b4,Te6edf3colorTb4b4b4:Te6edf3#000Tb4b4b4;
Te6edf3classDef Te6edf3androidTff7b72-Te6edf3feature Te6edf3fillTb4b4b4:Te6edf3#FFD6A5Tb4b4b4,Te6edf3strokeTb4b4b4:Te6edf3#000Tb4b4b4,Te6edf3strokeTff7b72-Te6edf3widthTb4b4b4:T79c0ff2Te6edf3pxTb4b4b4,Te6edf3colorTb4b4b4:Te6edf3#000Tb4b4b4;
Te6edf3classDef Te6edf3androidTff7b72-Te6edf3library Te6edf3fillTb4b4b4:Te6edf3#9BF6FFTb4b4b4,Te6edf3strokeTb4b4b4:Te6edf3#000Tb4b4b4,Te6edf3strokeTff7b72-Te6edf3widthTb4b4b4:T79c0ff2Te6edf3pxTb4b4b4,Te6edf3colorTb4b4b4:Te6edf3#000Tb4b4b4;
Te6edf3classDef Te6edf3androidTff7b72-Te6edf3libraryTff7b72-Te6edf3compose Te6edf3fillTb4b4b4:Te6edf3#9BF6FFTb4b4b4,Te6edf3strokeTb4b4b4:Te6edf3#000Tb4b4b4,Te6edf3strokeTff7b72-Te6edf3widthTb4b4b4:T79c0ff2Te6edf3pxTb4b4b4,Te6edf3colorTb4b4b4:Te6edf3#000Tb4b4b4;
Te6edf3classDef Te6edf3androidTff7b72-Te6edf3test Te6edf3fillTb4b4b4:Te6edf3#A0C4FFTb4b4b4,Te6edf3strokeTb4b4b4:Te6edf3#000Tb4b4b4,Te6edf3strokeTff7b72-Te6edf3widthTb4b4b4:T79c0ff2Te6edf3pxTb4b4b4,Te6edf3colorTb4b4b4:Te6edf3#000Tb4b4b4;
Te6edf3classDef Te6edf3jvmTff7b72-Te6edf3library Te6edf3fillTb4b4b4:Te6edf3#BDB2FFTb4b4b4,Te6edf3strokeTb4b4b4:Te6edf3#000Tb4b4b4,Te6edf3strokeTff7b72-Te6edf3widthTb4b4b4:T79c0ff2Te6edf3pxTb4b4b4,Te6edf3colorTb4b4b4:Te6edf3#000Tb4b4b4;
Te6edf3classDef Te6edf3kmpTff7b72-Te6edf3feature Te6edf3fillTb4b4b4:Te6edf3#FFD6A5Tb4b4b4,Te6edf3strokeTb4b4b4:Te6edf3#000Tb4b4b4,Te6edf3strokeTff7b72-Te6edf3widthTb4b4b4:T79c0ff2Te6edf3pxTb4b4b4,Te6edf3colorTb4b4b4:Te6edf3#000Tb4b4b4;
Te6edf3classDef Te6edf3kmpTff7b72-Te6edf3libraryTff7b72-Te6edf3compose Te6edf3fillTb4b4b4:Te6edf3#FFC1CCTb4b4b4,Te6edf3strokeTb4b4b4:Te6edf3#000Tb4b4b4,Te6edf3strokeTff7b72-Te6edf3widthTb4b4b4:T79c0ff2Te6edf3pxTb4b4b4,Te6edf3colorTb4b4b4:Te6edf3#000Tb4b4b4;
Te6edf3classDef Te6edf3kmpTff7b72-Te6edf3library Te6edf3fillTb4b4b4:Te6edf3#FFC1CCTb4b4b4,Te6edf3strokeTb4b4b4:Te6edf3#000Tb4b4b4,Te6edf3strokeTff7b72-Te6edf3widthTb4b4b4:T79c0ff2Te6edf3pxTb4b4b4,Te6edf3colorTb4b4b4:Te6edf3#000Tb4b4b4;
Te6edf3classDef Tff7b72unknown Te6edf3fillTb4b4b4:Te6edf3#FFADADTb4b4b4,Te6edf3strokeTb4b4b4:Te6edf3#000Tb4b4b4,Te6edf3strokeTff7b72-Te6edf3widthTb4b4b4:T79c0ff2Te6edf3pxTb4b4b4,Te6edf3colorTb4b4b4:Te6edf3#000Tb4b4b4;


<!--endregion-->

Overview

The T383838:core:ble module contains the foundation for Bluetooth Low Energy (BLE) communication in the Meshtastic Android app. It uses the Kable multiplatform BLE library to provide a unified, Coroutine-based architecture across all supported targets (Android, Desktop, and future iOS).

This module abstracts platform-specific BLE operations behind common Kotlin interfaces (T383838BleDevice, T383838BleScanner, T383838BleConnection, T383838BleConnectionFactory), ensuring that business logic in T383838commonMain remains platform-agnostic and testable.

Key Components

1. T383838BleConnection
A robust wrapper around Kable's T383838Peripheral that simplifies the connection lifecycle and service discovery using modern Coroutine APIs.

Features:
Connection & Await: Provides suspend functions to connect and wait for a terminal state (Connected or Disconnected).
Unified Profile Helper: A T383838profile function that manages service discovery, characteristic setup, and lifecycle in a single block, with automatic timeout and error handling.
Observability: Exposes T383838connectionState as a Flow for reactive UI and service updates.
Platform Setup: Seamlessly handles platform-specific configuration (like MTU negotiation on Android or direct connections on Desktop) via T383838platformConfig() extensions.

2. T383838BluetoothRepository
A Singleton repository responsible for the global state of Bluetooth on the device.

Features:
State Management: Exposes a T383838StateFlow<BluetoothState> reflecting whether Bluetooth is enabled, permissions are granted, and which devices are bonded.
Permission Handling: Centralizes logic for checking Bluetooth and Location permissions across different platforms.
Bonding: Simplifies the process of creating and validating bonds with peripherals.

3. T383838BleScanner
A wrapper around Kable's T383838Scanner to provide a consistent and easy-to-use API for BLE scanning with built-in peripheral mapping.

4. T383838BleRetry
A utility for executing BLE operations with retry logic, essential for handling the inherent unreliability of wireless communication.

Integration in T383838app

The T383838:core:ble module is used by T383838BleRadioInterface in the main application module to implement the T383838RadioTransport interface for Bluetooth devices.

Usage

Dependencies are managed via the version catalog (T383838libs.versions.toml).

T282828
Tff7b72[Tff7b72versionsTff7b72]
Te6edf3kable Tff7b72= Ta5d6ff"Ta5d6ff0.42.0Ta5d6ff"

Tff7b72[Tff7b72librariesTff7b72]
Te6edf3kable-core Tff7b72= Tb4b4b4{ Te6edf3module Tb4b4b4= Ta5d6ff"Ta5d6ffcom.juul.kable:kable-coreTa5d6ff"Tb4b4b4, Te6edf3versionTb4b4b4.Te6edf3ref Tb4b4b4= Ta5d6ff"Ta5d6ffkableTa5d6ff" Tb4b4b4}


Architecture

The module follows a clean multiplatform architecture approach:

Repository Pattern: T383838BluetoothRepository mediates data access.
Coroutines & Flow: All asynchronous operations use Kotlin Coroutines and Flows.
Dependency Injection: Koin is used for dependency injection.

Testing

The module includes unit tests for key components, utilizing Kable's architecture and standard coroutine testing tools to ensure logic correctness.

Served by rngit 1.5.0 - Generated in 0.05s